<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
</head>
<body class="no-skin">
<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <%--搜索栏--%>
                <div>
                    <%--承办单位--%>
                    <select multiple="true" onchange="searchTable('/taskMain/dubanDeptQuery/')" class="deptIds" id="deptIds1" placeholder="请输入或点击选择承办单位"
                            style="width: 210px;height: 33px;"></select>
                    <%-- 储存部门id--%>
                    <input type="text" value="" name="" class="deptrespts" hidden>
                    <input type="text" class="beginTimes form-control date-picker" placeholder="请选择开始时间"
                           title="请选择开始时间"
                           style="width: 210px;display: inline-block;" onchange="searchTable('/taskMain/dubanDeptQuery/')">

                    <input type="text" class="endTimes form-control date-picker" placeholder="请选择结束时间"
                           title="请选择结束时间"
                           style="width: 210px;display: inline-block;" onchange="searchTable('/taskMain/dubanDeptQuery/')">
                </div>
                <div style="margin-top:10px;">
                    <input type="text" style="width: 280px;" class="searchs" placeholder="请输入搜索内容"
                           onchange="searchTable('/taskMain/dubanDeptQuery/')">
                    <button class="btn btn-primary search-btns" onclick="searchTable('/taskMain/dubanDeptQuery/')">搜索</button>
                    <button class="btn btn-primary resets">重置</button>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

    <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
</div><!-- /.main-container -->
</div>

<!-- footer -->
<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<script src="<s:url value="/assets/js/own.js"></s:url>"></script>

<script type="text/javascript">
    // 基本路径
    var baseUrl = "<s:url value="/taskMain/dubanDeptQuery/"></s:url>"

    // jqgrid的表格高度
    var height = 320;
    // jqgrid表格行头的中文
    var colNames = ['','单号', '任务名称', "特殊任务id", "办理时限", "状态说明","逾期说明","任务附件"];

    var colModel = [
        {name: 'specialTaskId', width: 60, hidden: true, key: true},
        {name: 'sysId', index: 'sysId', width: 250, editable: true},
        {name: 'mainName', index: 'mainName', width: 250, editable: true},
        {name: 'specialTaskId', index: 'specialTaskId', width: 250, editable: true},
        {name: 'timeLimit', index: 'timeLimit', width: 250, editable: true},
        {name: 'typeExplain', index: 'typeExplain', width: 250, editable: true },
        {name: 'overdueExplain', index: 'overdueExplain', width: 250, editable: true},
        {name: 'file', index: 'file', width: 250, editable: true}
    ];
    //
    // /**
    //  * 任务类型格式化
    //  */
    // function categoryIdFormatter(data) {
    //     let mz = '';
    //        $.ajax({
    //            url:getUrl("categoryName")+data,
    //            type:"get",
    //            dataType:'json',
    //            async:false,
    //            success:function (data) {
    //                mz = data.category;
    //            }
    //        })
    //     return mz;
    // }
    //
    // /**
    //  * 附件格式化
    //  */
    // function fileFormatter(data) {
    //     if (data == null || data == "") {
    //         return "无任务附件";
    //     } else {
    //         return '<input type="button" value="下载" onclick="downDetail(\'' + data + '\')" \n' +
    //             ' style="width: 100%; height: 32px;" class="btn-large btn-primary"/>';
    //     }
    // }
    //
    // /**
    //  * 取消选中
    //  */
    // function gridRemoveSelect(rowid) {
    //     rowids.remove(rowid);
    // }
    // /**
    //  * 添加选中
    //  */
    // function gridAddSelect(rowid) {
    //     rowids.push(rowid);
    // }


    // jqgrid的具体执行方法
    var rowIds;
    var rowids = [];//选中行id
    jqgrid({
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager",
        autoScroll: false,
        shrinkToFit: false,
        onSelectRow: function (rowid, status) {
            rowIds = rowid;
            //选择当前的行
            var selectedRowValue = $("#gridTable").jqGrid('getRowData', rowid);
            var types = selectedRowValue.type;//获取任务状态
        },
        loadComplete:function (data) {
            var ids = $("#gridTable").jqGrid("getDataIDs");
            var rowDatas = $("#gridTable").jqGrid("getRowData");//获取所有行的数据
        },
        onSelectAll:function (aRowids,status){
            //全选
            if (!status) {
                aRowids.forEach(function(value,index){
                    gridRemoveSelect(value);
                });
            } else {
                aRowids.forEach(function(value,index){
                    var flag = false;
                    for (var i = 0; i< rowids.length; i++){
                        if(rowids[i] ==  value){
                            flag = true;
                            continue;
                        }
                    }
                    if(!flag){
                        gridAddSelect(value);
                    }
                });
            }
        },
        gridComplete: function () {
            var rowIds = jQuery("#gridTable").jqGrid('getDataIDs');
            for (var k = 0; k < rowIds.length; k++) {
                var flag = false;
                for (var i = 0; i < rowids.length; i++) {
                    if (rowids[i] == rowIds[k]) {
                        flag = true;
                        continue;
                    }
                }
                if (flag && flag == true) {
                    jQuery("#gridTable").setSelection(rowIds[k], true);
                }
            }
        },
        //双击列表事件：
        ondblClickRow:function (rowid) {
            /**
             * 打开二级页面
             */
            var selectedRowValue = $("#gridTable").jqGrid('getRowData', rowid);
                parent.openapp("/taskMain/dubanfeedback/"+rowid,rowid,"接收单位")
        }
    });

    /**
     * 重写Array
     */
    Array.prototype.remove = function (val) {
        var index = this.indexOf(val);
        if (index > -1) {
            this.splice(index, 1);
        }
    };

    /**
     * 重写Array
     */
    Array.prototype.indexOf = function (val) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == val) return i;
        }
        return -1;
    };


</script>

</body>
</html>